package com.imti.mall.product.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.imti.mall.model.pms.pojo.PmsProductAttribute;
import com.imti.mall.model.pms.pojo.PmsProductAttributeCategory;
import com.imti.mall.model.pms.vo.PmsProductAttributeVo;
import com.imti.mall.product.mapper.PmsProductAttributeDynaSqlProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;

import java.util.List;

/**
 * ClassName: PmsProductAttributeDao
 * Description:
 * date: 2022/9/13 13:51
 *
 * @author: youhun
 * @version:
 * @since JDK 1.8
 */
@Mapper
public interface PmsProductAttributeDao extends BaseMapper<PmsProductAttribute> {
    /**
     * 动态sql修改商品属性表
     *
     * >type字段用于控制其是规格还是参数
     * @param pmsProductAttributeVo
     * @return
     */
    @UpdateProvider(type =PmsProductAttributeDynaSqlProvider.class ,method = "updatePmsProductAttribute")
    public boolean updatePmsProductAttribute(PmsProductAttributeVo pmsProductAttributeVo);
    /**
     * 动态sql查询列表
     * @param pmsProductAttribute
     * @return
     */
    @SelectProvider(type= PmsProductAttributeDynaSqlProvider.class ,method = "findPmsProductAttribute")
    public List<PmsProductAttribute> findPmsProductAttribute(PmsProductAttribute pmsProductAttribute);

    @SelectProvider(type= PmsProductAttributeDynaSqlProvider.class ,method = "getPmsProductAttribute")
    public int getPmsProductAttribute(PmsProductAttribute pmsProductAttribute);

    /**
     * 查询属性和参数数量
     * @param pmsProductAttribute
     * @return
     */
    @Select("SELECT COUNT(TYPE) FROM `pms_product_attribute` WHERE 'TYPE'=#{type} AND product_attribute_category_id=#{productAttributeCategoryId}")
    public int countPmsProductAttribute(PmsProductAttribute pmsProductAttribute);
}
